# -*- coding: utf-8 -*-

import codecs
import wx.stc

class scintilla(wx.stc.StyledTextCtrl):    
    def __init__ (self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, name = "editor"):
        self.settings = wx.GetApp().GetSettings()
        wx.stc.StyledTextCtrl.__init__ (self, parent, id, pos, size, style, name)
        self.encoder = codecs.getencoder(u"utf-8")
        self.SetViewWhiteSpace(self.settings["ShowWhiteSpace"])
        self.SetViewEOL(self.settings["ShowEOL"])
        
        # Формат файла
        if self.settings["DefaultEOLMode"] == u"CRLF":
            self.SetEOLMode(wx.stc.STC_EOL_CRLF)
        elif self.settings["DefaultEOLMode"] == u"CR":
            self.SetEOLMode(wx.stc.STC_EOL_CR)
        else:
            self.SetEOLMode(wx.stc.STC_EOL_LF)
        
        # Нумерация строк       
        if self.settings["ShowLineNumbers"]:
            self.SetMarginType(1, wx.stc.STC_MARGIN_NUMBER)
            self.SetMarginWidth(1, 25) # Ширина поля
            
        self.SetCaretForeground("BLACK")
        if wx.Platform == u"__WXMSW__":
            self.StyleSetSpec(wx.stc.STC_H_DEFAULT, u"face:Courier New,fore:#000000,face:Courier New,size:%s" % self.settings[u"FontSize"])
        elif wx.Platform == u"__WXGTK__":
            self.StyleSetSpec(wx.stc.STC_H_DEFAULT, u"face:Monospace,fore:#000000,face:Monospace,size:%s" % self.settings[u"FontSize"])